﻿using System;
using DemoCompositeService.DataContracts;
using DemoCompositeService.DemoServiceSvcRef;

namespace DemoCompositeService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "CompositeDemo" in code, svc and config file together.
    public class CompositeDemo : ICompositeDemo
    {

        public MyDataContractCompositeOutput Do(MyDataContractInputComposite input)
        {
            var client = new DemoServiceClient();
            var remoteServiceInput = new MyDataContractInput();
            remoteServiceInput.TestItem1 = "test1234";
            remoteServiceInput.TestItem2 = "4321Test";
            var header = new MyHeader();
            
            var remoteResult = client.MyTestOperation(header , remoteServiceInput);
            if (string.IsNullOrEmpty(remoteResult.ResponseItem1))
            {
                throw new Exception("remoteresult.responseitem1 can not be empty!!!");
            }

            var output = new MyDataContractCompositeOutput();
            output.ResponseItem1 = "item1";
            output.ResponseItem2 = false;

            return output;
        }
    }
}
